package com.mz.ozy.mvp.model;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;

import com.mz.ozy.constants.Constants;
import com.mz.ozy.net.RetrofitUtils;
import com.mz.ozy.utils.JsonUtils;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class MeModel {
    public Observable<ResponseBody> getAccountInfo(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10007, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getBusInfo(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10032, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getUpBusInfo(Context context, String type, String wechatid) {
        Map<String, String> maps = new HashMap<>();
        maps.put(type, wechatid);

        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10033, JsonUtils.requestJsonDate(maps), Constants.tokenId);

    }

    public Observable<ResponseBody> getBindInfo(Context context, String type, String id) {
        Map<String, String> maps = new HashMap<>();
        maps.put("type", type);
        maps.put("id", id);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10065, JsonUtils.requestJsonDate(maps), Constants.tokenId);

    }

    public Observable<ResponseBody> getALiInfo(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10062, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getVipUpInfo(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10317, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getVipUpDataInfo(Context context, String id, int type) {
        if (type == 0) {
            Map<String, String> maps = new HashMap<>();
            return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10051, JsonUtils.requestJsonDate(maps), Constants.tokenId);
        } else {
            Map<String, String> maps = new HashMap<>();
            return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10309, JsonUtils.requestJsonDate(maps), Constants.tokenId);
        }
    }

    public Observable<ResponseBody> getVipUpSh(Context context, int type) {
        if (type == 0) {
            Map<String, String> maps = new HashMap<>();
            return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10052, JsonUtils.requestJsonDate(maps), Constants.tokenId);
        } else {
            Map<String, String> maps = new HashMap<>();
            return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10309, JsonUtils.requestJsonDate(maps), Constants.tokenId);
        }
    }

    public Observable<ResponseBody> getFriendInfo(Context context, String page) {
        Map<String, String> maps = new HashMap<>();
        maps.put("pageNo", page);
        maps.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10050, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getVipUpJs(Context context, String certificate, String id, int type) {
        String url = "";
        if (type == 0) {
            url = Constants.TransCode.TransCode10053;
            if (!TextUtils.isEmpty(id)) {
                url = Constants.TransCode.TransCode10305;
            }
        } else {
            url = Constants.TransCode.TransCode10310;
            if (!TextUtils.isEmpty(id)) {
                url = Constants.TransCode.TransCode10311;
            }
        }
        Map<String, String> maps = new HashMap<>();
        maps.put("certificate", certificate);
        if (!TextUtils.isEmpty(id)) {
            maps.put("id", id);
        }
        return RetrofitUtils.getApiService(context).post(url, JsonUtils.requestJsonDate(maps), Constants.tokenId);

    }

    public Observable<ResponseBody> getMeInfo(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10006, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> applyResMeet(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10323, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> applyMeet(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10324, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getMybounsInfo(Context context, int type) {
        if (type == 0) {
            Map<String, String> maps = new HashMap<>();
            return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10054, JsonUtils.requestJsonDate(maps), Constants.tokenId);
        } else if (type == 1) {
            Map<String, String> maps = new HashMap<>();
            return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10306, JsonUtils.requestJsonDate(maps), Constants.tokenId);
        } else {
            Map<String, String> maps = new HashMap<>();
            return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10312, JsonUtils.requestJsonDate(maps), Constants.tokenId);
        }
    }

    public Observable<ResponseBody> getUnreadMsg(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10332, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    /**
     * @param context
     * @param mobilePhone 手机号
     * @return
     */
    public Observable<ResponseBody> onGetCode(Context context, String mobilePhone) {
        Map<String, String> map = new HashMap<>();
        map.put("username", mobilePhone);
        map.put("actionType", "P");
        map.put("t", Constants.tokenId);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10001, JsonUtils.requestJsonDate(map), null);
    }

    public Observable<ResponseBody> onGeUp(Context context, String uname, String cardid, String code) {
        Map<String, String> map = new HashMap<>();
        map.put("uname", uname);
        map.put("cardid", cardid);
        map.put("code", code);
        map.put("t", Constants.tokenId);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10010, JsonUtils.requestJsonDate(map), null);
    }

    public Observable<ResponseBody> getMybounsRecode(Context context, String page, String url) {
        Map<String, String> maps = new HashMap<>();
        maps.put("pageNo", page);
        maps.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(url, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getBalanceInfo(Context context, String page, String url) {
        Map<String, String> maps = new HashMap<>();
        maps.put("pageNo", page);
        maps.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(url, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> changeLanguage(Activity activity, String lang) {
        Map<String, String> maps = new HashMap<>();
        maps.put("lang", lang);
        return RetrofitUtils.getApiService(activity).post(Constants.TransCode.TransCode00000, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> getXy(Context activity, String lang) {
        Map<String, String> maps = new HashMap<>();
        maps.put("type", lang);
        return RetrofitUtils.getApiService(activity).post(Constants.TransCode.TransCode10060, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> uploadHeader(Context context, String useravatar, String nickname) {
        Map<String, String> maps = new HashMap<>();
        maps.put("useravatar", useravatar);
        maps.put("nickname", nickname);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10008, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> exitLogin(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10071, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    /**
     * 取消绑定
     *
     * @param context
     * @param type    1-微信  2-支付宝
     * @return
     */
    public Observable<ResponseBody> onCancelBind(Context context, int type) {
        HashMap<String, String> maps = new HashMap<>();
        maps.put("type", type + "");
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10009, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> onVipPay(Context context, String id, String payType) {
        Map<String, String> maps = new HashMap<>();
        maps.put("id", id);
        maps.put("payType", payType);

        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10318, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }


    public Observable<ResponseBody> newBonus(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10402, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> newBonusDetail(Context context, String page, String type) {
        Map<String, String> maps = new HashMap<>();
        maps.put("pageNo", page);
        maps.put("pageSize", Constants.PageSize);
        maps.put("type", type);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10411, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> newBonusDonate(Context context, String amount, String exUid, String payPwd) {
        Map<String, String> maps = new HashMap<>();
        maps.put("amount", amount);
        maps.put("exUid", exUid);
        maps.put("paypwd", payPwd);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10406, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> newGQ(Context context, String page) {
        Map<String, String> maps = new HashMap<>();
        maps.put("pageNo", page);
        maps.put("pageSize", Constants.PageSize);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10413, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> checkJoinMember(Context context) {
        Map<String, String> maps = new HashMap<>();
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10414, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

}
